<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

    <script>
        //1.使用setTimeout
        //1秒之后 会回调这个函数  ()=>{console.log('Hello');}
       /*  setTimeout(()=>{
            console.log('hello world');
            console.log('hello world');
            console.log('hello world');
            console.log('hello world');
            console.log('hello world');

            setTimeout(()=>{
                console.log('Hello Vue');
                console.log('Hello Vue');
                console.log('Hello Vue');
                console.log('Hello Vue');
                console.log('Hello Vue');

                setTimeout(()=>{
                    console.log('Hello Python');
                    console.log('Hello Python');
                    console.log('Hello Python');
                    console.log('Hello Python');
                    console.log('Hello Python');
                })
            })
        },1000) */



        //解除了嵌套地狱

        //Promise就是对一些异步操作进行一些疯转
       //创建Promise的时候里面的参数本质也是一个函数(resolve,reject)
       //resolve、reject本身又是函数
        new Promise((resolve,reject)=>{
            //第一次网络请求的代码
            setTimeout(()=>{
                resolve()
            },1000)
        }).then(()=>{
            //第一次拿到结果的处理代码
            console.log("hello world");
            console.log("hello world");
            console.log("hello world");
            console.log("hello world");
            console.log("hello world");

            return new Promise((resolve,reject)=>{
                //第二次网络请求的代码
                setTimeout(()=>{
                    resolve()
                },1000)
            })
        }).then(()=>{
                //第二次处理的代码
                console.log('Hello Vue');
                console.log('Hello Vue');
                console.log('Hello Vue');
                console.log('Hello Vue');
                console.log('Hello Vue');

                return new Promise((resolve,reject)=>{
                    //第三次网络请求的代码
                    setTimeout(()=>{
                        resolve()
                    })
                })
        }).then(()=>{
            //第三次处理的代码
            console.log('Hello Python');
                    console.log('Hello Python');
                    console.log('Hello Python');
                    console.log('Hello Python');
                    console.log('Hello Python');
        })
    </script>


</body>
</html>